home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ham Radio 2000
/
Ham Radio 2000.iso
/
ham2000
/
antenna
/
azproj10
/
az_proj.ps
< prev
next >
Wrap
Text File
|
1995-07-19
|
143KB
|
5,209 lines
%%--------------------------------------
%% AZ_PROJ.PS v1.0
%%Creator: Joseph Mack NA3T (ex VK2ZJM/VK2BME) and Michael Katzmann NV3Z/VK2BEA/G4NYV
%%Title: az_proj.ps Ver 1.0
%%CreationDate: Thu 19 Jul 95
%
% Last modification 19 Jul 95, JM
% Is Joe's file az_projz.ps
%
%--------------------------------------
% A 'beta' version was released at the Central States and
% the Eastern States VHF Conferences, 1994 for evaluation purposes.
% This is the first general release version.
% You may freely redistribute this version.
% Note: the data file format is incompatible with that of the beta release -
% don't mix versions.
%--------------------------------------
% AZ_PROJ.PS (C) 1994, 1995 Joseph Mack NA3T and Michael Katzmann NV3Z/VK2BEA/G4NYV
%
% AZ_PROJ.PS is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2, or (at your option)
% any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% You should have received a copy of the GNU General Public License
% along with AZ_PROJ.PS; see the file COPYING. If not, write to
% the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
%
% AZ_PROJ.PS - A program to print Azimuthal equidistant map projections
% on a Postscript device or via a Postscript interpreter (e.g. ghostscript)
% If you find any bugs or have ideas for enhancements, please code them
% and send them to us. We will post updates occasionally, and include
% your code with acknowledgment.
% We are contactable at -
% Joseph Mack NA3T, (FM19gk)
% 528 Grant Pl
% Frederick, MD. 21702-4142, USA (will be moving from here Aug 95)
%
% call me in this order please
% e-mail: mack@ncifcrf.gov (will be valid after move)
% ph: USA (301)-662-3486 (home - evenings only please -
% - message machine usually, OK till 10pm = 0300 UTC)
% Michael Katzmann NV3Z / VK2BEA / G4NYV, (FM18rx)
% 501 Defense Highway
% Annapolis, MD. 21410-6923
%
% e-mail: michael%vk2bea@secondsource.COM
% packet: nv3z@w3zh.md
% ph: USA (410) 672-3900 (work EST, UTC -5hrs)
%--------------------------------------
% PostScript is a trademark of Adobe Systems, Incorporated.
% Ghostscript is Copyright (C) 1990, 1992, 1993 Aladdin Enterprises.
% DesqviewX is a trademark of Quarterdeck.
% Note: the az_proj files are PostScript. They run on any platform
% that understands PostScript, eg a PostScript printer or a PC, Mac,
% or Unix box running a PostScript interpreter (eg Ghostscript).
%
% The az_proj files were verified on these platforms:
% - NEC LC890 Silentwriter with Adobe Postscript (Level 1)
% - HP1200C/PS Color deskjet with Adobe Postscript (Level 2)
% - Ghostscript 2.6.2 executing under MSDOS 6.2, MS Windows 3.1
% or DesqviewX v2.0/ghostscript_dvx v2.6.1, v3.1.2, v3.3.3
% operating under MSDOS5.0, both on
% Intel 486 hardware with hardcopy output to HP Deskjet550C.
% - Ghostscript 2.6.2 executing under HP/UX 9.0 X11R5
% on HP9000/380 with hardcopy output to HP Deskjet 500.
% On a Mac Quadra 950 and Phaser II color printer.
% Ghostscript is freely available (with the GNU License) from
% ftp.cs.wisc.edu:/pub/ghost, and from the GNU servers everywhere.
% The Jul '94 price for Ghostscript on PC diskettes is US$48
% (includes shipping, handling, etc) payable by check or money
% order to Aladdin Enterprises and mailed to:
%
% Aladdin Enterprises
% 203 Santa Margarita Ave.
% Menlo Park, CA, 94025, USA
%
% The author of ghostscript, L. Peter Deutsch is contactable at
% Aladdin Enterprises
% P.O.Box 60264,
% Palo Alto, CA 94306, USA
% or at
% ghost@aladdin.com
% decwrl!aladdin!ghost
% voice USA (415)-322-0103
% fax USA (415)-322-1734
%
%--------------------------------------
%
% n.b. Execution times vary greatly with platforms. Many Postscript
% printers are not be equipped with floating point hardware and
% will consequently be slow. (also consider the time taken to
% send in excess of 4MB of data files to the printer!)
%
% some benchmarks (full world database & annotations):
% Ghostscript on HP9000/380 X11R5 - 8 mins
% Ghostscript on i486 (66MHz) VGA - 7 mins
% HP1200C/PS printer - 2.1 hrs
% NEC LC890 PS printer - 6.7 hrs
%
%--------------------------------------
% Modus operandi for
% a) native Postscript printers
% b) Postscript Interpreters running on host computers,
% which output native print codes for the target printer.
%
%Input files:
% If you have a native Postscript Printer
% A real postscript printer can only listen to the line down which
% the postscript file itself is sent. Postscript printers don't,
% in general, know about files (the exception is Display PS)
% When a PS printer gets an EOF it knows it has come to
% the end of the job. If you want to print a map of the whole
% world on a real postscript printer you must make ONE file by
% concatonating "az_proj.ps" and, all of the data files (eg ".wdb",
% dxcc.dat, beacon.dat). i.e. the data must appear as an uninterrupted
% stream.
%
% Note that the data will be drawn on the page in the order received
% by the printer. e.g. One beacon is on the edge of the Great Lakes.
% If beacons are drawn first, this beacon will be overwritten by the
% lake (if drawn in "fill" mode). So send beacons after lakes and countries.
%
% for DOS:
% The command line would then be something like
% C:\> PRINT AZ_COMB.PS
% where AZ_COMB.PS is the combined data file. The combined data
% file can be produced by a file similar to makworld.bat
% (supplied with AZ_PROJ) that has the one line instruction -
%
% C:\>copy az_ini.ps+az_proj.ps+africa.wdb+antarct.wdb+eurasia.wdb+n_amer.wdb+
% oceania.wdb+s_amer.wdb+dxcc.dat+beacon.dat+ctrld.ps az_comb.ps
% (all on one line)
%
% for UNIX:
% $ cat az_ini.ps az_proj.ps *.wdb dxcc.dat |lp
%
% n.b. when using an Adobe Postscript equipped printer, You MUST
% have an EOF character (ctrl D, ^D) at the end of the data stream .
% Most printer spoolers designed for a PS printer will do this
% but if they don't, you must explicitly supply it. The file
% 'ctrld.ps' (supplied with azproj), can be used for this task,
% as in the DOS example above.
%
%Ghostscript processed files
% Ghostscript is a program, run on a computer, which interprets
% the Postscript language and outputs print codes suitable for
% specific printers and screens.
% Ghostscript knows about files. You can send multiple .WDB
% files to ghostscript as command line parameters.
%
% MS-DOS:
% The command line for screen viewing (see AZVIEW.BAT), would then be
% C:\> gs386 -q az_ini.ps -- az_proj.ps n_amer.wdb dxcc.dat
%
% To create to a print file `n_amer.cdj' (see AZPRINT.BAT),
% which can then be sent to a HP deskjet 550 (all on one line)
% gs386 -q -sDEVICE=cdj550 -sOutputFile=n_amer.cdj az_ini.ps --
% az_proj.ps n_amer.wdb dxcc.dat
%
% Note that the MSDOS command PRINT will only work for ascii files.
% The file n_amer.cdj is binary must be printed using something like
% C:>copy/b n_amer.cdj lpt1:
% (Better to use a good DOS spooler like the shareware dmp)
%
% The following command sends directly to PRN
% gs386 -q -sDEVICE=cdj550 az_ini.ps -- az_proj.ps n_amer.wdb dxcc.dat
%
% UNIX: to send directly to the printer
% (without creating an intermediate file):
% gs -q -sDEVICE=cdj550 '-sOutputFile=|lp -or -onb' \
% -r300 -dNOPAUSE az_ini.ps -- az_proj.ps n_amer.wdb dxcc.dat
%--------------------------------------
% Credits, Thanks and more explanations
% WDB files
% The data files come from the Micro World Data Bank II (MWDB-II).
% Mike Owen W9IP pointed us to this resource.
% The binary data was converted by one of the utility programs
% in the set, to the ASCII form used here (the .wdb files).
% Each line in the .wdb files has the form
% integer lat lon comment
% representing a point on the earth's surface. If the integer
% is a 4 digit number then this point is the start of
% a new path (ie line) to be drawn on the earth's surface.
% The four digit integer is a label showing -
% 1xxx, coast lines
% 2xxx, country borders
% 3xxx, Canadian Provinces
% 4xxx, US state borders
% 5xxx, islands
% 6xxx, lakes
% 7xxx, rivers
% 8xxx, Australian States
% A new 4 digit integer terminates an old path and starts a new one.
%
% If the integer is a single digit, it has the value 1..5 and
% represents the resolution level (1 - highest detail, 5 - least detail).
% If you want faster (and less detailed) plotting, then only the lower
% resolution data need be used. We haven't had time to implement this
% feature, consequently all data is plotted everytime. Anything in
% the data line after the first three numbers is ignored by this
% program. Comments or names of the features (eg `% Lake Baikal')
% can be put at the end of the data line.
%
% The original .wdb files, as extracted from the database, are sorted
% into separate files for countries, coasts, rivers, lakes, islands etc.
% If you are a VHF operator, you are more likely to be using data for
% one continent, so I have manually sorted the data into continent files
% (n_amer.wdb, oceania.wdb etc), each file having the coastlines,
% countries, islands, states, rivers, lakes for that continent.
% If you are plotting the top of Siberia using the file eurasia.wdb
% and want N.A. to appear in the same plot, then you will have to
% send the file n_amer.wdb to the printer as well.
% Originally the lower numbered lines (eg 2xxx) were first in
% the .wdb files. However if a river (6xxx) or lake (7xxx) is also
% a political border, then the black political line is later
% covered over with a green (river) or blue (lake) line.
% In case you're looking for a black political borders, and don't
% want them covered by a colored river, I've moved the rivers and lakes
% to an earlier part of the WDB files. Thus the Rio Grande is a (green)
% river in New Mexico, but as it travels south it becomes a (black)
% border between Texas and Mexico. It looks a little weird to see a
% colored line change back and forth to a black line. It's my best
% solution so far. If you've any better ideas, let me know. If you're
% watching the map being drawn on a screen, you will see the rivers
% and lakes drawn before country and state borders.
% A partial solution is to make the state borders dashed
% (see /state_borders_dashed).
%
% The lines which describe the lakes are have been hand modified
% so that they are now closed paths. So it is now possible to fill
% a lake with one color or just to stroke the outline (see the
% variable /lake_fill). (Anyone have the co-ords for Lake
% Champlain, Lake Fromme... ?)
%
% Here are some of the notations that come with the WDB -
%
% "The full WDB-II is a digital map data base produced by the
% Central Intelligence Agency (CIA) and distributed by the National
% Technical Information Service (NTIS), U.S. Department of Commerce,
% 5285 Port Royal Road, Springfield, VA, 22161.
% ...
%
% This documentation and the associated files are placed in the
% public domain and may incorporated into other products without fee so
% long as appropriate credits are included. An appropriate credit line
% would be - "This product contains/uses data and/or code placed in the
% public domain by Fred Pospeschil and Antonio Riveria. Original
% coordinate data was created by the Central Intelligence Agency."
%
% ALL USERS OF THESE MATERIALS ARE TOTALLY RESPONSIBLE FOR THEIR
% USE AS THESE MATERIALS ARE PROVIDED WITHOUT EITHER EXPRESS OR IMPLIED
% WARRANTIES OF ANY KIND."
%
% - end of excerpt from the WDB docs.
% Routine GC
% The routine gc was adapted from gc.c, Ver 1.01
% S. R. Sampson, N5OWK, Public Domain (p) November 1989,
% Ref: Air Force Manual 51-40, "Air Navigation", 1 February 1987
% Call/zone file (dxcc.dat):
% The ARRL list of dxcc call zones in machine readable form
% is maintained by Bill Brelsford, K2DI.
% The file is available by ftp to
% ftp.cs.buffalo.edu:/pub/ham-radio/dxcc-k2di
% or by sending e-mail containing the line
% send dxcc-k2di
% to info@arrl.org
% The listing we are using was updated in 1 Jul 94. Note that
% while the .WDB files have been broken down into continents,
% the dxcc.dat file is for the whole world. If you combine
% only one continent file and the dxcc file, you will get
% some dxcc names printed in the "sea".
%Annotation file (annotation):
% To add a notation to the map, supply data in the form
% annotate:Notation:Lat:Lon
% eg. annotate:NV3Z:38.98847N:76.58033W
%Beacon File
% To add a beacon to the map, supply data in the form
% beacon:frequency Callsign Grid_locator Power Direction
% eg. beacon:144.170 KH6HME BK29go 60 90 1
% (if no beam direction is given or if it is 360, then it is omni)
% (the trailing '1' is a flag to print the info below the symbol,
% rather than on top, which is the default. The flag is optional)
% The beacon file, bea_w3ep.dat, is maintained by Emil Pocock, W3EP.
% Emil writes the `World above 50MHz' column in QST. Please send
% beacon updates to Emil and we will get them from him.
% Sorry, this file we have only has US beacons.
% The 6m beacon file, bea_6m.dat, is from
% M. Harrison, <poa01@cc.keele.ac.uk>.
%
% CAVEAT: Some of the beacons are directional. Unless the
% beacon is relatively close (say 500-100km depending on
% the accuracy you're interested in), then the path of the
% radio wave (which is following a great circle) will be
% curved on the map (like the lines of constant longitude).
% Only the great circle lines to and from the QTH are straight
% on this projection. So if the beacon is pointing at you on
% the azimuthal projection map it will be pointing at you in
% physical reality too. However if the map says it is pointing
% somewhere else, you may not even be able to guess the path
% of the radio wave on the map surface. For that you should do
% a projection from the beacon's site.
%
%Repeater files:
% A repeater file has the same format as a beacon file.
% The lines start with r: and R: (rather than b: and B:),
% so that repeaters can be differentiated from beacons.
% Unfortunately the ARRL is not allowed to release the contents
% of their repeater directory, because of a non-release clause
% required by most repeater coordinators before parting with
% their lists. Apparently repeater information is regarded as
% proprietary by repeater coordinators. If you are able to pry
% your local repeater coordinator's fingers off his list then
% you can put repeaters on your map.
%
% NMEA capabilities - suggested by Paul Wade N1BWT, and with help
% on the code specs by Mike Owen W9IP, an article by Wayne Simpson
% forwarded by Paul, and a lead to a WWW site by Jim KC7MJ
% only GLL (Geog Lat/Lon)
% and BWC (bearing to waypoint along Great Circle) are implemented.
%
% for info on NMEA, see the file simpson.doc included in this package
%
%--------------------------------------
% Bugs & Caveats:
%
%Limitations
%1: Can't do maps from the poles (directions are south and north
% to everywhere respectively). You can make a map that looks just fine
% from say (89.9,180.0) though. Be careful of the longitude
% you pick as this will define the reference direction.
%2: Reference Latitude and Longitude lines near the antipodes will
% wrap around by crossing back across the map. If your QTH is exactly
% on a plotted reference latitude, e.g. 15.00000 deg N, then try
% entering 15.001 deg N instead.
%3: Postscript can be very slow when implimented in some printers.
% For a real postscript printer, maps take 20mins to 8hrs depending
% on what you plot. Ghostscript running under DesqviewX
% on a 33MHz 486 computer takes *about* 1/2hr for plotting Nth America.
% Running under MS-DOS, it takes just over 2 mins. The Ghostscript
% screen viewer only takes a few minutes for small parts of the
% earth's surface. Remember that if you send it the whole map
% for Europe and are only looking at your local 100km, the
% program still has to calculate the whole of Europe and Asia.
% You might want to split off a particular part of your files
% if you're going to do a lot of plots of one area.
% If you re-sort any files like this into useful groupings
% please send us the new files, as it may save someone doing
% the same thing again.
%Problems near the poles:
% Due to what appears to be the single precision arithmetic
% of postscript, the routine "gc" cannot differentiate points close
% together near the poles. It becomes impossible to calculate the
% orientation of number labels near the pole for instance. These
% calculations, when they result in a divide by 0 error, are trapped
% and those labels are not drawn.
%Bugs:
%1: Get a numeric exception if QTH = (0,0) and DEST = (90,90)
%
%2: Elapsed time doesn't work in DesqviewX 2.0, with ghostscript 2.6.1
%
%3: There are lots of comments to help you understand the code.
% However this slows down operation when used on a native
% Postscript printer particularly when fed by a serial line.
% Solution: Create a copy and strip out all the comments.
% You can remove comments with utilities like the freeware
% CLNCODE2, available on your local BBS.
%Fiddles:
%Close points:
% There are lots of problem points and discontinuities on a sphere
% Points "near" the antipodes are given a bearing of 0 deg
% Points closer than the numerical precision (= very_small_distance)
% are given a bearing of 0 deg. To be safe, I've defined
% "very_small_distance" to be just smaller than the resolution
% of the data. The resolution of the WDB, is 1min of arc = 0.016 deg
% (1 mile at the equator). The ASCII translation of the database
% is given to 3 figs i.e. 0.001 deg, although the original data
% is only accurate to 0.016 degree.
%
% "very_small_distance" is the distance in degrees at which the
% routines will assume that DEST=QTH. This trap is to stop the
% bearing determining routine from blowing up when trying
% to determine the bearing to yourself from yourself, with
% limited precision calculations. In choosing this quantity,
% anything less than the smallest interval being plotted is OK.
%
%Distant points:
% The bearing to points at the antipodes is not defined.
% Distances close to the antipodes are trapped and a
% bearing of 0 will be returned.
%--------------------------------------
/starttime usertime def
% gives a nonsense value with ghostscript running under DesqviewX
% but sensible numbers everwhere else
%--------------------------------------
%initialise and declare a few things
%strings, defined here to stop it chewing up VM
/grid_string 10 string def
/name 10 string def
/COMMA (,) def
/CR (\r) def
/LF (\n) def
/temp_string 10 string def
%Conversions % Distances: All distance calculations are done in degrees
% along great circles, assuming a spherical earth.
/km2deg { 10000 div 90 mul } def
/deg2km { 10000 mul 90 div } def
/NM2deg {360 mul 21600 div} def %Nautical Miles
/M2deg {360 mul 25000 div} def %Statute Miles (25000 or whatever the circumference is)
/cm { 28.35 mul } def % points in a centimeter
/points2cm { 28.35 div } def
%Routines
% Only define arccos if it is not built in (as in ghostscript)
systemdict /arccos known not { /arccos /Arccos cvx def } if
%other useful things
/very_small_distance 0.001 def
/distance_to_antipodes 180.0 very_small_distance sub def
/incr_lim 1.0e-3 def
%--------------------------------------
%Grid square nomenclature:
% The 2x1 degree "squares" are described by a pair of letters,
% eg. FM for Mid Atlantic USA.
% In this program the 2x1 deg squares are called "letter_squares"
%
% The 0.2x0.1 degree squares are described by a pair of numbers,
% eg. 19 for Washington, DC area.
% In this program the 0.2x0.1 deg squares are called "number_squares"
% The number squares are useful for VHF operators operating over
% short distances. If drawing a large map (radius > 50 degrees)
% then the number squares are turned off automatically.
% Irrespective of the scale being plotted, all (i.e. the whole
% world) of the letter grid squares are calculated (even if you
% are only plotting 100 km out from your QTH). We haven't
% figured an automatic way that can short circuit this process.
% It doesn't take a lot of time compared to processing the .wdb files,
% or compared to the printing so we haven't done anything to speed it up.
%--------------------------------------
% linewidths of map features (in atom units (1/2000 * picture height))
/feature_width
[
2.0 % coast lines
1.5 % country borders
1.25 % Canadian Provinces
1.25 % US state boundaries
2.0 % islands
1.0 % lakes
1.25 % rivers
1.0 % Australian State boundaries
] def
%--------------------------------------
% handy numbers to make code readable
/coast_line 1 def
/country_border 2 def
/Canadian_province 3 def
/US_state 4 def
/island 5 def
/lake 6 def
/river 7 def
/Australian_state 8 def
%--------------------------------------
/bearing_fontsize { atom 20 mul } def
/footer_label_height { atom 30 mul } def
/annot_font /Helvetica-Oblique def
/annot_font_size { atom 30 mul } def
/mountain_font /Helvetica def
/mountain_font_size { atom 30 mul } def
/rover_font /Helvetica def
/rover_font_size { atom 30 mul } def
/beacon_font_size { atom 15 mul } def
/width_mh { atom } def %letter grid locator line width
/fine_gl_width { atom 2 div } def %number grid locator line width
/bearing_width { atom } def
%--------------------------------------
% calculate sun_lat from day of year
% 88 days to 22 March
% sun_lat is 23.5 sin (((day_of_year -88)/365)x360)
%
% calculate sun_lon from UTC
% sun_lon is (0.5-(minutes_of_day/1440))x360
% no leap years
/days_in_month [0 31 28 31 30 31 30 31 31 30 31 30] def
/calculate_sun_position
{
az_dict /month known
az_dict /day known and
az_dict /hour known and
az_dict /min known and
{
(Calculating sun position \n) print_notice
0 1 month 1 sub
{
%array index is on stack
days_in_month %array name
exch %get in right order to retrieve array element
get
%(days in month ) print_notice pstack
day add /day exch def
}for
% day now contains day of year
day
%(day of year ) print_notice pstack
88 sub
365.25 div 360 mul
sin
23.5 mul
/sun_lat exch def
%sun_lat (sun_lat ) print_notice pstack pop
hour 60 mul min add 1440 div 0.5 sub neg 360 mul /sun_lon exch def
%sun_lon (sun_lon ) print_notice pstack pop
} if
}def
%--------------------------------------
% Error function for greyline
% If this function is zero then the terminator lat (term_lat)
% and lon (term_lon) are correct.
% This is used in a Newton iteration to find term_lat, given term_lon
% formula supplied by Chris Cosgrove at Sydney Uni.
/terminator_error
{
% term_lat on stack
% term_lon global
% sun_lat, sun_lon are globals
% error is left on the stack on exit
/term_lat exch def
sun_lat cos term_lat cos mul
sun_lon term_lon sub cos mul
sun_lat sin term_lat sin mul
add
%(terminator_error: ) print_notice pstack
}def
%--------------------------------------
% draw sun symbol at sun_lat, sun_lon
/draw_sun_symbol
{
/dot_radius 5 atom mul def
/sun_radius 20 atom mul def
/inner_end_of_ray 30 atom mul def
/ray_length 10 atom mul def
1 atom mul setlinewidth
greyline_color setrgbcolor
sun_lat sun_lon lat_lon2xy moveto
newpath
sun_lat sun_lon lat_lon2xy dot_radius 0 360 arc closepath fill
newpath
%sun_lat sun_lon lat_lon2xy moveto
sun_lat sun_lon lat_lon2xy sun_radius 0 360 arc stroke
%draw rays around sun
7 /number_of_rays_around_sun exch def
0 360 number_of_rays_around_sun div 360
{
newpath
sun_lat sun_lon lat_lon2xy moveto
dup rotate
inner_end_of_ray 0 rmoveto
ray_length 0 rlineto stroke
neg rotate
} for
}def
%--------------------------------------
% Greyline routine
% calculates position of greyline using the global values, sun_lat, sun_long
% being the point at which the sun is directly overhead.
% assumes a spherical earth.
%
% sun_lat, sun_lon come from az_ini.ps
% or are calculated from date/time in az_ini.ps
% or date/time from NMEA codes (whenever that gets put in)
%
% for sun overhead at sun_lat, sun_lon the equation of the terminator
% (term_lat, term_lon) is
% cos(sun_lat).cos(term_lat).cos(sun_lon - term_lon)
% + sin (sun_lat).sin(term_lat) = 0
% not easy to get the answer explicitely, (due to div by zero)
% so do it iteratively
%
% BUGS:
% This is a quick and dirty routine.
% 1. It has trouble with terminators going through the poles,
% eg at the equinoxes (will execute but produce garbage).
% i.e. when sun_lat=0.0
% this is trapped below
%
% 2. The terminator line is calculated at even intervals of term_lon rather
% than using the contour_draw algorythm (even intervals of plotting space).
% So lines of most interest to some, ie where the greyline goes through
% your QTH, will have jaggy lines around the antipodes,
% while the lines near the QTH will be drawn in unnecessary detail. Oh well.
%
% 3. I can't tell which part of the map is day or night, so I
% can't make one part of the map grey (ie the night side).
% If you figure it out, let me know.
% In the meantime, I've put a marker for the sun on the map.
%
/greyline
{
(Drawing Greyline \n) print_notice
%sun_lat (sun_lat ) print_notice pstack pop
%sun_lon (sun_lon ) print_notice pstack pop
/Helvetica findfont bearing_fontsize scalefont setfont
1 atom mul setlinewidth
greyline_color setrgbcolor
0.1 /inc exch def % inc for newton iteration
% where terminator crosses equator, ie where term_lat=0
% (ie term_lat and term_lon are known - a good place to start calculating)
%sun_lon = (sun_lon) print_notice
sun_lon 90 sub /phase_of_node exch def
phase_of_node -180 lt {phase_of_node 180 add /phase_of_node exch def} if
phase_of_node 180 gt {phase_of_node 180 sub /phase_of_node exch def} if
%phase_of_node = (phase_of_node) print_notice
% initialise lat_term, will get new value each iteration along terminator
0.0 /term_lat exch def % = 0.0 for first iteration
%trap sun_lat == 0.0
0.0 sun_lat eq {0.5 /sun_lat exch def} if % much smaller and you get garbage
mark %just in case
newpath
% go to node
term_lat phase_of_node lat_lon2xy moveto
%draw path
%go 360 deg starting at equatorial crossing of terminator
phase_of_node 0.1 phase_of_node 360 add
{
%(term_lon ) print_notice pstack
/term_lon exch def
{
% find slope i.e. d(terminator_error)/d(term_lon)
term_lat terminator_error dup /y1 exch def % y1
term_lat inc add terminator_error % y2
sub % y1 - y2
inc div /error_slope exch def
%(error_slope ) print_notice error_slope pstack pop
error_slope dup mul 0.00000001 lt {exit} if % in case are at a stationary point
y1 error_slope div /shift exch def %calculate Newton Shift
term_lat shift add /term_lat exch def % calculate new term_lat
shift 0.0001 lt {exit} if % exit if done
%term_lat (term_lat ) print_notice pstack pop
%(going around again \n) print_notice
} loop % till Newton has converged
term_lat term_lon lat_lon2xy lineto
%term_lat term_lon pstack pop pop
} for
closepath
stroke
cleartomark %as I said, just in case
}def
%--------------------------------------
%Instruction to execute to display a "special" dxcc country
% ie one marked with a D: in dxcc.dat
/dxcc_special_country_2
{
/outlineshow {true charpath stroke} def
atom 10 div setlinewidth
/Helvetica-BoldOblique findfont
/dxcc_font_size { atom 30 mul} def % as a fraction of screen width
dxcc_font_size scalefont setfont
dxcc_special_color_2 setrgbcolor
} def
%Instruction to execute to display a dxcc country in that you've worked
/dxcc_special_country
{
/outlineshow {true charpath stroke} def
atom 10 div setlinewidth
/Helvetica-BoldOblique findfont
/dxcc_font_size { atom 25 mul} def % as a fraction of screen width
dxcc_font_size scalefont setfont
dxcc_special_color setrgbcolor
} def
%Instruction to execute to display a dxcc country in default mode
% eg for a country that you haven't worked
/dxcc_country
{
/outlineshow {show} def
/Helvetica findfont
/dxcc_font_size { atom 25 mul } def % as a fraction of screen width
dxcc_font_size scalefont setfont
dxcc_color setrgbcolor
} def
%--------------------------------------
% special cases
/island_in_lake
% these islands are in a lake.
% they have to be drawn after the lake and filled with white
% otherwise they will be blue (or whatever color your lake is)
[
5173
5174
5175
5200
]def
/big_lakes % big enough to have borders in black
% I've somewhat arbitrarily decided which lakes are in this list
% you can put them all in if you like.
% it's an ad hoc solution otherwise small lakes become all edge
% entries one per line, you can take a lake out of this list,
% by putting a comment (%) symbol at the start of the line
[
6058 % L. Winnipeg
6059 % Great Slave Lake
6060 % L. Athabasca
6061 % L. Ontario
6062 % L. Erie
6063 % Thunder Bay
6069 % Great Bear Lake
%6070 % Teslin Lake (border BC and Yukon)
6073 % Caspian Sea and part of L. Winnipeg (don't ask me why these have the same numbers, I didn't do the numbering)
6074 % L. Ontario
%6087 % L. Okeechobee
6096 % L. Nicaragua
6501 % L. Nettilling (in Baffin Is.)
]def
%--------------------------------------
%Things to do:
%Cities
% It would be nice to be able to display cities, in a way that only
% important (whatever that means) towns are displayed on large scale
% maps while on small scale maps, less important towns are brought in.
% In the hopes of using populations as a measure of importance, I
% unsuccessfully scoured the universe for computer readable files of
% town names, lat/lon and populations. They weren't available, despite
% all the population planning that is done by organisations like the UN.
% Presumably planning is still done with pencils and erasers. The
% hardcopy available (several hundred pages), which indeed does have
% all the info needed, was dual language Fr/Eng and in a format and
% range of fonts designed to outwit any scanning hardware/software
% combination known to man. Apparently this hardcopy was produced without
% any computer intervention as there is no trace of the original data.
%
% The author of Traksat, Paul Traufler kindly offered his traksat.cty
% file for non-commercial use, but this list does not have a method
% for ranking the cities. We've put the problem off till a later
% version of the program. If anyone would like to go through
% Paul's file of 1690 cites and rank them in importance from
% say 1..5 in a way that's compatible with Paul's planned future
% use of the file, and send it to us, we would be very happy indeed.
%--------------------------------------
%Start of routines
%--------------------------------------
/setup_variables
[
/lat_QTH /lon_QTH /QTH_name
/lat_center /lon_center /center_offset
/map_scale_deg /scale_type
/landscape
/draw_letter_square_borders /draw_letter_square_labels
/draw_number_square_borders /draw_number_square_labels
/draw_compass_circumference /draw_compass_spokes
/draw_outer_border
/DXCC_callsigns
] def
/process_options_manual
{
az_dict /scale_type known
{
scale_type
{
/kms_per_cm map_scale_deg def
} if
} if
}def
/process_options
{
/vno 0 def
options
{
dup type
{
dup /stringtype eq
{
pop
setup_variables vno get dup
az_dict exch known
{
dup cvx exec type /stringtype eq
{
exch def exit
}{
pop exit
} ifelse
}{
exch def exit
} ifelse
} if
dup /booleantype eq
{
pop
setup_variables vno get dup
az_dict exch known
{
dup cvx exec type /booleantype eq
{
exch def exit
}{
pop exit
} ifelse
}{
exch def exit
} ifelse
} if
dup /integertype eq
{
pop cvr /realtype
} if
/realtype eq
{
setup_variables vno get dup
az_dict exch known
{
dup cvx exec type /realtype eq
1 index cvx exec type /integertype eq or
{
exch def exit
}{
pop exit
} ifelse
}{
exch def exit
} ifelse
} if
} loop
/vno vno 1 add def
setup_variables length vno eq { exit } if
} forall
az_dict /scale_type known
{
scale_type
{
/kms_per_cm map_scale_deg def
} if
} if
DXCC_callsigns not
{
/dxcc_info Cntry def
} if
} def
%--------------------------------------
% Printer problems - weird and otherwise
/setup_specific
{
% The ghostscript3.2.8 printer driver for the Color HP DJ550c gives the wrong
% clippath for the printable region. The driver for this printer ignores
% the 1/4" or so of paper at the end of the page that the rollers need
% to hold the paper. The clippath is used to locate labels currently
% at the bottom left of the page and the Title. It is also used to determine
% font size.
% If your printer has similar problems, modify this routine for your
% printer and send it to us (address above)
/printer_fiddle {} def % your routine
% Default routine to modify the the values of LLx LLy URx URy
% returned from the bounding box of clippath. Several Ghostscript
% printer drivers (cdj500 and Epson) are known to give erronious
% values.
% It is executed in "setup_dimensions"
statusdict /product get (Ghostscript) search % are we running Ghostscript?
{
pop pop pop
%the devicename call changed at gs3xx
currentdevice revision 300 lt {devicename}{.devicename} ifelse
{
dup (cdj550) eq % are we outputting for a cdj550c ?
{
/printer_fiddle
landscape
{
% fix clippath for landscape mode
(landscape clippath fix for cdj550 \n) print_notice
{ 4 -1 roll 0.28 cm add 4 1 roll }
}
{
% fix clippath for portrait mode
(portrait clippath fix for HP DeskJet 550 \n) print_notice
{ 3 -1 roll 0.28 cm add 3 1 roll }
} ifelse
def
% also do gamma correction
(gamma correction for HP DeskJet 550 \n) print_notice
{ 0.2 exp } dup dup currenttransfer setcolortransfer
pop exit
} if % cdj550
dup (djet500) eq % outputting to a HP Deskjet 500 ?
{
% this gives a better grey scale than the default screen I think
60.0 45.0
{
abs exch abs 2 copy add 1 gt
{ 1 sub dup mul exch 1 sub dup mul add 1 sub }
{ dup mul exch dup mul add 1 exch sub } ifelse
} setscreen
(grey scale correction for HP DeskJet 500 \n) print_notice
{ 2 exp } settransfer
pop exit
} if %djet500
% The epson driver gives wrong values for the clippath, so a
% simillar 'printer fiddle' as the cdj550 is needed here.
% We've found no problems with the (limited number of)
% other drivers we've tried (add them here and send them to us).
pop exit
} loop % all printers
} %if Ghostscript
{
pop
} ifelse % not Ghostscript
%Do gamma correction for color PostScript printers
%A word or two about gamma correction
%(only for those outputing to color printers).
% A printer gives a brightness that is linearly dependant on input
%(much as you would expect), i.e if you send {1,0,0} setrgbcolor
%to the printer , it will produce a red that is twice as bright
%(measured presumably in electric field) as will sending
%{0.5,0,0} setrgbcolor. A screen however, due to the physics
%of phosphors, will give output proportional to input^^gamma,
%where 2.2<gamma<2.5, i.e. the output increases faster than
%linearity. Since the brightness at red =0 and red =1 are
%normalised for both printer and screen, the difference in
%output on the two devices will be noticed at mid-intensity
%output. The printer output will be darker than the screen.
%Thus the color lightblue as used here ({0.33,0.33,1} setrgbcolor),
%which is the default lake color, looks skyblue on a screen,
%but dark blue on a printer.
%
% So there's a printer convention and a screen convention.
%No attempt has been made to make the output colors device
%independant. You send your output device the instructions
%and take what you get. If you want the color on the printer
%to look the same as the color on the screen preview you
%can do a gamma correction. The problem is to detect whether
%you need to correct or not. There isn't any way (that we know
%of) for the code to know whether it's running on a color
%printer or a screen, or whether a color printer has the
%color or the B&W